
<div class="layui-fluid">

    <div class="layui-row layui-col-space5">
        <div class="layui-col-md4">
            <div class="layui-card">

                <div class="layui-card-header">
                    <script type="text/html" template>
                        {{#return layui.admin.getTableTitle('system-customParameter')}}
                    </script>
                </div>

                <div class="layui-card-body">
                    <table id="system-customParameter-table" lay-filter="system-customParameter-table"></table>
                </div>
            </div>
        </div>
        <div class="layui-col-md8">
            <div class="layui-card">

                <div class="layui-card-header">
                    <script type="text/html" template>
                        {{#return layui.admin.getTableTitle('system-customParameterItem')}}
                    </script>
                </div>

                <div class="layui-card-body">

                    <form class="layui-form layui-card-header layuiadmin-card-header-auto" nosearchbtn id="system-customParameterItem-search-form" lay-filter="system-customParameterItem-search-form">
                        <div class="layui-form-item">
                            <input type="hidden" name="ParentID" compare="ParentID" />
                        </div>
                    </form>
                    <table id="system-customParameterItem-table" lay-filter="system-customParameterItem-table"></table>
                    <script type="text/html" id="system-customParameterItem-toolbar"></script>
                </div>
            </div>
        </div>

    </div>

</div>

<script>
    layui.use(['reTable', 'reTreeGrid'], function () {
        var $ = layui.$
            , reTable = layui.reTable
            , reTreeGrid = layui.reTreeGrid
            , reForm = layui.reForm
            , table = layui.table
            , admin = layui.admin;

        var MemberName = 'MemberName' + admin.lang;


        var parameter = {
            tableId: 'system-customParameter'
            , tableOptions: {
                url: ''
                , idField: 'DictionaryID'
                , where: { order: MemberName, SearchWhere: JSON.stringify([{ compare: 'ParentID', condition: '=', SearchValue: '975dd569-2820-4a94-b79a-62253bcdb8d3' }]) }
                , cellMinWidth: 140
                , cols: [[
                    { type: 'numbers' }
                    , { field: MemberName, title: "名称" }
                ]]
            }

            , tableEvent: function () {
                table.on('row(system-customParameter-table)', function (obj) {

                    $('#system-customParameterItem-search-form [name="ParentID"]').val(obj.data.DictionaryID);
                    reTreeGrid.tableSearch('system-customParameterItem');

                    obj.tr.addClass('layui-table-click').siblings().removeClass('layui-table-click');
                });
            }
        }

        reTable.initTable(parameter);

        var parameterItem = {
            tableId: 'system-customParameterItem'
            , tableOptions: {
                url: ''
                , idField: 'DictionaryID'
                , treeId: 'DictionaryID'
                , treeUpId: 'ParentID'
                , treeShowName: 'Member'
                , isPage: false
                , where: { order: MemberName, SearchWhere: JSON.stringify([{ searchValue: '00000000-0000-0000-0000-000000000000', condition: '=', compare: 'ParentID' }]) }
                , cellMinWidth: 140
                , cols: [[
                    { type: 'numbers' }
                    , { field: 'Member', title: '编号' }
                    , { field: MemberName, title: '名称' }
                    , { title: admin.operationCell, width: 160, align: 'center', fixed: 'right', toolbar: '#system-customParameterItem-toolbar' }
                ]]
            }
            , toolbarFun: {
                add: function (d) {
                    reForm.popupForm({
                        title: admin.getToolbarFormTitle('system-customParameterItem', 'add')
                        , url: 'admin/system/customParameterItemForm'
                        , formLay: 'system-customParameterItem-form'
                        , subUrl: '/Admin/saveDictionary'
                        , initData: { LockParentID: d.ParentID, ParentID: d.DictionaryID }
                        , done: function (res) {
                            reTreeGrid.tableSearch('system-customParameterItem');
                        }
                    })
                }
            }
            , delUrl: '/Admin/delDictionary'
            , formOptions: {
                url: 'admin/system/customParameterItemForm'
                , subUrl: '/Admin/saveDictionary'
                , initData: function () { return { ParentID: $('#system-customParameterItem-search-form [name="ParentID"]').val() } }
            }
        }

        reTreeGrid.initTreeGrid(parameterItem);

    });
</script>